//
//  Feed.h
//
// RE:: comments
// class Feed interface
//
// An object of this type corresponds to a source on the Web of many Posts / stories
//

#import <Foundation/Foundation.h>

// Tell the compiler to chill out --- these *are* real classes and they *will* show up somewhere in this project
@class ASIHTTPRequest, Channel;

// We agree to play by the rules set forth in the NSXMLParserDelegate protocol:
// We want to be the one that the NSXMLParser object calls when it has a message to send, so
//    we will implement the methods it says we need to implement to handle these messages that it sends
//    [these are marked below as they occur]
@interface Feed : NSObject <NSXMLParserDelegate> {
	
	NSURL *feedURL;		// Web location of our Feed data source
	ASIHTTPRequest *feedRequest;	// Wrapper object for a request for data from the Web ---
									//    hides hideous tech details
	
	Channel *feedChannel;	// Self-descriptive info about the data source, internal to the XML glop
	NSMutableArray *feedPosts; // Array to hold Posts as we untangle them from the XML from the Feed source
	
	id currentElement;	// Hangs onto the id (pointer-to) of the XML element *currently* being decoded from XML
						//    (in this app, with be either a Channel or a Post element that we plan to dump into a 
						//     Channel or Post object in our own local data Model)
	NSMutableString *currentElementData;	// Buffer to collect the gooey center of an XML element as it is being
											//    decoded --- we may append strings to this *several times* before
											//    we're done
	
	// General sequence of use of these last two iVars:
	//      0. We keep an eye on XML tags as they show up in the XML data, watching for 
	//            the start of a Channel or Item (Post) element
	//		1. We grab and hold onto the id of a Channel or Post element that we're interested in
	//		2. Over and over, we stick text from inside that element to our element data buffer, until
	//      3. We reach the end of the element, then we close out the buffer and save its contents to 
	//            the appropriate iVar inside the Channel or Post object
	//
	

}

@property (nonatomic, copy) NSURL *feedURL;
@property (nonatomic, retain) ASIHTTPRequest *feedRequest;
@property (nonatomic, retain) Channel *feedChannel;
@property (nonatomic, retain) NSMutableArray *feedPosts;
@property (nonatomic, assign) id currentElement;
@property (nonatomic, retain) NSMutableString *currentElementData;


- (id)initWithURL:(NSURL *)feedURL;
- (void)refresh;

// Strings to hold our homemade names of the kinds of events we want the Notification Center to tell our delegate about
extern NSString *kFeederReloadCompletedNotification;
extern NSString *kFeederReloadFailedNotification;

@end
